from tkinter import *
from tkinter import messagebox

root = Tk()

def callback():
    if messagebox.askokcancel('Hi', 'Is this ok?'):
        print('yes is ok')
    else:
        print('no is not ok')

button = Button(root, text='Button2', command=callback)
button.pack()
root.mainloop()
